package com.example.sketchpaddemo;

import android.animation.ValueAnimator;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {
    private Sketchpad sketchpad;

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        sketchpad = findViewById(R.id.myView);
        /*ValueAnimator valueAnimator = ValueAnimator.ofFloat(0,500);
        valueAnimator.setDuration(5000);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                sketchpad.setCurrencenter(value);
            }
        });

        valueAnimator.start();*/

        /**
         * 红色
         */

        findViewById(R.id.btn1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sketchpad.setPaintColor(Color.RED);
            }
        });

        /**
         * 蓝色
         */
        findViewById(R.id.btn2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sketchpad.setPaintColor(Color.BLUE);
            }
        });

        /**
         * 矩形
         */
        findViewById(R.id.btn3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sketchpad.setPaintMode(Sketchpad.RECT);
            }
        });

        /**
         * 圆形
         */
        findViewById(R.id.btn4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sketchpad.setPaintMode(Sketchpad.CIRCLE);
            }
        });
        /**
         * 画笔
         */
        findViewById(R.id.btn5).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sketchpad.setPaintMode(Sketchpad.PEN);
            }
        });

        /**
         * 清楚
         */
        findViewById(R.id.btn6).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sketchpad.clear();
            }
        });
    }
}
